package com.yourname.xhs.bean;

import java.util.Arrays;

public enum Category {


    KNOWLEDGE("KNOWLEDGE", 1),
    FOOD("FOOD", 2),
    TRAVEL("TRAVEL", 3),
    SPORTS("SPORTS", 4),
    LIFE("LIFE", 5),
    TECHNOLOGY("TECHNOLOGY", 6);
    private int index;
    private String name;

    Category(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public static Category getCategoryByIndex(int index) {
        for (Category category : Category.values()) {
            if (category.getIndex() == index) {
                return category;
            }
        }
        System.out.println("输入错误，请重新输入：");
        return null;
    }

    public int getIndex() {
        return index;
    }

}
